package cn.itcast.zt.rateLimiter;

import com.google.common.util.concurrent.RateLimiter;
import lombok.extern.slf4j.Slf4j;

/**
 * create by zhangtian on 2018/4/12
 */
@Slf4j
public class RateLimiterExample1 {

    private static RateLimiter rateLimiter = RateLimiter.create(5) ;

    public static void main(String[] args) {
        for(int index = 0; index < 100; index++){
            rateLimiter.acquire();
            handle(index);
        }
    }

    private static void handle(int index) {
        log.info("{}", index);
    }
}
